/**
 * AudioUpload.java
 * Wraps an uploaded audio file in an audio data access object.
 */
package com.example.myproject;


public class AudioUpload {
	
	public AudioUpload(){}
	
	/**
	 * Uploads an audio file to the blobstore.
	 * @param src The source audio file to be uploaded.
	 * @param master 
	 * @return true if successfully uploaded, false if not.
	 */
	public boolean upload(UploadDTO master, String genre, String album)
	{
		
		try {
			
			AudioUploadDTO audio = new AudioUploadDTO();
			AudioUploadDAO adao = new AudioUploadDAO();
				
			audio.setTitle(master.getTitle());
			audio.setContentType(master.getContentType());
			audio.setPath(master.getPath());
			audio.setParentId(master.getId());
			audio.setGenre(genre);
			audio.setAlbum(album);
			audio.setCaption(master.getCaption());
			adao.save(audio);
			return true;
			
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		
	}

}